package com.es.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 描述:
 * es-servlet-
 *
 * @author Derek
 * 创建时间：2022-04-21 9:35
 */
/*
@WebServlet(urlPatterns = "/loginServlet")
@WebInitParam(name = "encoding", value = "utf-8")

 */
public class LoginServlet extends HttpServlet {
    @Override
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletConfig config = this.getServletConfig();
        String encoding = config.getInitParameter("encoding");
        request.setCharacterEncoding(encoding);
        System.out.println("HelloWorld");
        String name = request.getParameter("name");
        //
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();

        out.println("<h3>欢迎回来:"+name+"</h3>");
        out.flush();
    }
}
